package o;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.jsoup.SerializationException;
import org.jsoup.nodes.Document;

public abstract class gbq implements Cloneable {
    int ˋ;
    public gbq ॱ;

    static class e implements gcq {
        private org.jsoup.nodes.Document.e ˏ;
        private Appendable ॱ;

        e(Appendable appendable, org.jsoup.nodes.Document.e eVar) {
            this.ॱ = appendable;
            this.ˏ = eVar;
            eVar.ˋ();
        }

        public void ˏ(gbq o_gbq, int i) {
            try {
                o_gbq.ˋ(this.ॱ, i, this.ˏ);
            } catch (Throwable e) {
                throw new SerializationException(e);
            }
        }

        public void ˎ(gbq o_gbq, int i) {
            if (!o_gbq.ˎ().equals("#text")) {
                try {
                    o_gbq.ˊ(this.ॱ, i, this.ˏ);
                } catch (Throwable e) {
                    throw new SerializationException(e);
                }
            }
        }
    }

    protected abstract void ˊ(Appendable appendable, int i, org.jsoup.nodes.Document.e eVar) throws IOException;

    protected abstract void ˋ(Appendable appendable, int i, org.jsoup.nodes.Document.e eVar) throws IOException;

    protected abstract void ˋ(String str);

    public abstract String ˎ();

    public abstract String ˏ();

    protected abstract boolean ˏॱ();

    public abstract gbi ͺ();

    public abstract int ॱ();

    protected abstract List<gbq> ॱˊ();

    public /* synthetic */ Object clone() throws CloneNotSupportedException {
        return ʻ();
    }

    protected gbq() {
    }

    public boolean ˋᐝ() {
        return this.ॱ != null;
    }

    public String attr(String str) {
        gbj.ˋ((Object) str);
        if (!ˏॱ()) {
            return "";
        }
        String ˏ = ͺ().ˏ(str);
        if (ˏ.length() > 0) {
            return ˏ;
        }
        if (str.startsWith("abs:")) {
            return ˏ(str.substring("abs:".length()));
        }
        return "";
    }

    public gbq ˋ(String str, String str2) {
        ͺ().ॱ(gbs.ˊ(this).ˎ().ॱ(str), str2);
        return this;
    }

    public boolean hasAttr(String str) {
        gbj.ˋ((Object) str);
        if (str.startsWith("abs:")) {
            String substring = str.substring("abs:".length());
            if (ͺ().ʼ(substring) && !ˏ(substring).equals("")) {
                return true;
            }
        }
        return ͺ().ʼ(str);
    }

    public void ˎ(final String str) {
        gbj.ˋ((Object) str);
        ˋ(new gcq(this) {
            final /* synthetic */ gbq ˊ;

            public void ˏ(gbq o_gbq, int i) {
                o_gbq.ˋ(str);
            }

            public void ˎ(gbq o_gbq, int i) {
            }
        });
    }

    public String ˏ(String str) {
        gbj.ॱ(str);
        if (hasAttr(str)) {
            return gbk.ॱ(ˏ(), attr(str));
        }
        return "";
    }

    public gbq ॱ(int i) {
        return (gbq) ॱˊ().get(i);
    }

    public List<gbq> ˍ() {
        return Collections.unmodifiableList(ॱˊ());
    }

    public gbq ˎˎ() {
        return this.ॱ;
    }

    public final gbq ˋˋ() {
        return this.ॱ;
    }

    public gbq ˌ() {
        while (this.ॱ != null) {
            this = this.ॱ;
        }
        return this;
    }

    public Document ˏˏ() {
        gbq ˌ = ˌ();
        return ˌ instanceof Document ? (Document) ˌ : null;
    }

    public void ˑ() {
        gbj.ˋ(this.ॱ);
        this.ॱ.ॱॱ(this);
    }

    public gbq ʽ(gbq o_gbq) {
        gbj.ˋ((Object) o_gbq);
        gbj.ˋ(this.ॱ);
        this.ॱ.ˏ(this.ˋ, o_gbq);
        return this;
    }

    protected void ʼॱ() {
    }

    public void ʼ(gbq o_gbq) {
        gbj.ˋ((Object) o_gbq);
        gbj.ˋ(this.ॱ);
        this.ॱ.ˋ(this, o_gbq);
    }

    protected void ʻ(gbq o_gbq) {
        gbj.ˋ((Object) o_gbq);
        if (this.ॱ != null) {
            this.ॱ.ॱॱ(this);
        }
        this.ॱ = o_gbq;
    }

    protected void ˋ(gbq o_gbq, gbq o_gbq2) {
        gbj.ˋ(o_gbq.ॱ == this);
        gbj.ˋ((Object) o_gbq2);
        if (o_gbq2.ॱ != null) {
            o_gbq2.ॱ.ॱॱ(o_gbq2);
        }
        int i = o_gbq.ˋ;
        ॱˊ().set(i, o_gbq2);
        o_gbq2.ॱ = this;
        o_gbq2.ˊ(i);
        o_gbq.ॱ = null;
    }

    protected void ॱॱ(gbq o_gbq) {
        gbj.ˋ(o_gbq.ॱ == this);
        int i = o_gbq.ˋ;
        ॱˊ().remove(i);
        ˋ(i);
        o_gbq.ॱ = null;
    }

    protected void ˏ(int i, gbq... o_gbqArr) {
        gbj.ˋ((Object[]) o_gbqArr);
        List ॱˊ = ॱˊ();
        for (gbq ᐝ : o_gbqArr) {
            ᐝ(ᐝ);
        }
        ॱˊ.addAll(i, Arrays.asList(o_gbqArr));
        ˋ(i);
    }

    protected void ᐝ(gbq o_gbq) {
        o_gbq.ʻ(this);
    }

    private void ˋ(int i) {
        List ॱˊ = ॱˊ();
        while (i < ॱˊ.size()) {
            ((gbq) ॱˊ.get(i)).ˊ(i);
            i++;
        }
    }

    public List<gbq> ˏˎ() {
        if (this.ॱ == null) {
            return Collections.emptyList();
        }
        List<gbq> ॱˊ = this.ॱ.ॱˊ();
        List<gbq> arrayList = new ArrayList(ॱˊ.size() - 1);
        for (gbq o_gbq : ॱˊ) {
            if (o_gbq != this) {
                arrayList.add(o_gbq);
            }
        }
        return arrayList;
    }

    public gbq ͺॱ() {
        if (this.ॱ == null) {
            return null;
        }
        List ॱˊ = this.ॱ.ॱˊ();
        int i = this.ˋ + 1;
        if (ॱˊ.size() > i) {
            return (gbq) ॱˊ.get(i);
        }
        return null;
    }

    public int ˎˏ() {
        return this.ˋ;
    }

    protected void ˊ(int i) {
        this.ˋ = i;
    }

    public gbq ˋ(gcq o_gcq) {
        gbj.ˋ((Object) o_gcq);
        gcm.ˏ(o_gcq, this);
        return this;
    }

    public String av_() {
        StringBuilder ˏ = gbk.ˏ();
        ॱ((Appendable) ˏ);
        return gbk.ˎ(ˏ);
    }

    protected void ॱ(Appendable appendable) {
        gcm.ˏ(new e(appendable, gbs.ˏ(this)), this);
    }

    public <T extends Appendable> T ˋ(T t) {
        ॱ((Appendable) t);
        return t;
    }

    public String toString() {
        return av_();
    }

    protected void ˎ(Appendable appendable, int i, org.jsoup.nodes.Document.e eVar) throws IOException {
        appendable.append('\n').append(gbk.ॱ(eVar.ʼ() * i));
    }

    public boolean equals(Object obj) {
        return this == obj;
    }

    public gbq ʻ() {
        gbq ˏ = ˏ(null);
        LinkedList linkedList = new LinkedList();
        linkedList.add(ˏ);
        while (!linkedList.isEmpty()) {
            gbq o_gbq = (gbq) linkedList.remove();
            int ॱ = o_gbq.ॱ();
            for (int i = 0; i < ॱ; i++) {
                List ॱˊ = o_gbq.ॱˊ();
                gbq ˏ2 = ((gbq) ॱˊ.get(i)).ˏ(o_gbq);
                ॱˊ.set(i, ˏ2);
                linkedList.add(ˏ2);
            }
        }
        return ˏ;
    }

    protected gbq ˏ(gbq o_gbq) {
        try {
            gbq o_gbq2 = (gbq) super.clone();
            o_gbq2.ॱ = o_gbq;
            o_gbq2.ˋ = o_gbq == null ? 0 : this.ˋ;
            return o_gbq2;
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}
